package com.motu.monstercity.server.game.base;

import com.motu.monstercity.protocol.Common.*;
import com.motu.monstercity.server.game.logic.RewardItem;
import com.motu.monstercity.server.game.userdata.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

//  pb数据的工具类
public class ProtoDataUtils {
    private static Logger logger = LoggerFactory.getLogger(ProtoDataUtils.class);

    // 更新客户端的飘窗提示信息
    public static void promptPBUserData(PBUserData.Builder pbUserData, RewardItem rewardItem) {
        if (pbUserData == null) {
            return;
        }
        PBRewardPrompt.Builder pbRewardPrompt = PBRewardPrompt.newBuilder();
        pbRewardPrompt.setItemId(rewardItem.getItemId());
        pbRewardPrompt.setNum(rewardItem.getItemNum());
        pbUserData.addPromptList(pbRewardPrompt);
    }

    // 把数据塞到pbuserdata的相应位置
    public static void updatePBUserData(PBUserData.Builder pbUserData, Object object) {
        updatePBUserData(pbUserData, object, false);// 默认调用takebuild方法
    }

    /**
     * 把数据塞到pbuserdata的相应位置
     * @param pbUserData
     * @param object
     * @param isFull 是否全量下发数据,true时调用takeinit方法
     */
    public static void updatePBUserData(PBUserData.Builder pbUserData, Object object, boolean isFull) {
        if (pbUserData == null || object == null) {
            return;
        }
        if (object instanceof UserInfo userInfo) {// 把userinfo 更新到pbuserdata里面
            pbUserData.getUserInfoBuilder().setUserInfo(isFull ? userInfo.takeInitBuilder() : userInfo.takeBuilder());
        }
        else if (object instanceof UserExtInfo userExtInfo) {
            pbUserData.getUserInfoBuilder().setUserExtInfo(isFull ? userExtInfo.takeInitBuilder() : userExtInfo.takeBuilder());
        }
        else if (object instanceof UserPower userPower) {
            pbUserData.getUserInfoBuilder().setUserPower(isFull ? userPower.takeInitBuilder() : userPower.takeBuilder());
        }
        else if (object instanceof UserAffair userAffair) {
            pbUserData.getUserInfoBuilder().setUserAffair(isFull ? userAffair.takeInitBuilder() : userAffair.takeBuilder());
        }
        else if (object instanceof UserAdvideo userAdvideo) {
            pbUserData.getUserInfoBuilder().setAdvideo(isFull ? userAdvideo.takeInitBuilder() : userAdvideo.takeBuilder());
        }
        else if (object instanceof UserPartner userPartner) {
            pbUserData.getPartnerBuilder().putPartnerList(userPartner.getPartnerId(),isFull ? userPartner.takeInitBuilder().build() : userPartner.takeBuilder().build());
        }
        else if (object instanceof UserWeapon userWeapon) {
            pbUserData.getPartnerBuilder().putWeaponList(userWeapon.getId(),isFull ? userWeapon.takeInitBuilder().build() : userWeapon.takeBuilder().build());
        }
        else if (object instanceof UserSuit userSuit) {
            pbUserData.getSuitBuilder().putSuitList(userSuit.getSuitId(),isFull ? userSuit.takeInitBuilder().build() : userSuit.takeBuilder().build());
        }
        else if (object instanceof UserSecretary userSecretary) {
            pbUserData.getSecretaryBuilder().putSecretaryList(userSecretary.getSecretaryId(),isFull ? userSecretary.takeInitBuilder().build() : userSecretary.takeBuilder().build());
        }
        else if (object instanceof UserSecretaryBusiness userSecretaryBusiness) {
            int secrId = userSecretaryBusiness.getSecretaryId();
            PBUserSecretary.Builder sb = PBUserSecretary.newBuilder();
            PBUserSecretary pbUserSecretary = pbUserData.getSecretaryBuilder().getSecretaryListMap().get(secrId);
            if (pbUserSecretary != null) {
                sb = pbUserSecretary.toBuilder();
            }
            sb.putBusiness(userSecretaryBusiness.getSkillId(), isFull ?  userSecretaryBusiness.takeInitBuilder().build() : userSecretaryBusiness.takeBuilder().build());
            pbUserData.getSecretaryBuilder().putSecretaryList(secrId, sb.build());
        }
        else if (object instanceof UserBuild userBuild) {
            pbUserData.getBuildBuilder().putBuildList(userBuild.getBuildId(),isFull ? userBuild.takeInitBuilder().build() : userBuild.takeBuilder().build());
        }
        else if (object instanceof UserCityInfo userCityInfo) {
            pbUserData.getBuildBuilder().setCityInfo(isFull ? userCityInfo.takeInitBuilder() : userCityInfo.takeBuilder());
        }
        else if (object instanceof UserSoldierRecover userSoldierRecover) {
            pbUserData.getBuildBuilder().setSoldierRecover(isFull ? userSoldierRecover.takeInitBuilder() : userSoldierRecover.takeBuilder());
        }
        else if (object instanceof UserCityCoord userCityCoord) {
            pbUserData.getBuildBuilder().putCoordList(userCityCoord.getCrood(),isFull ? userCityCoord.takeInitBuilder().build() : userCityCoord.takeBuilder().build());
        }
        else if (object instanceof UserBuildTile userBuildTile) {
            pbUserData.getBuildBuilder().putTileList(userBuildTile.getTileId(),isFull ? userBuildTile.takeInitBuilder().build() : userBuildTile.takeBuilder().build());
        }
        else if (object instanceof PBOffEarn.Builder pbOffEarn) {
            pbUserData.getBuildBuilder().setOffEarn(pbOffEarn);
        }
        else if (object instanceof UserItem userItem) {// 把userinfo 更新到pbuserdata里面
            pbUserData.getBagBuilder().putItemList(userItem.getItemId(), userItem.takeInitBuilder().build());
        }
        else if (object instanceof UserDating userDating ) {
            PBUserDatingData.Builder dating = pbUserData.getDatingBuilder();
            dating.setDating(isFull ? userDating.takeInitBuilder() : userDating.takeBuilder());
        }
        else if (object instanceof UserDatingSecretary userDatingSecretary){
            pbUserData.getDatingBuilder().putDatingSecretaryList(
                    userDatingSecretary.getSecretaryId(),isFull ? userDatingSecretary.takeInitBuilder().build() : userDatingSecretary.takeBuilder().build());
        }
        else if (object instanceof UserStage userStage) {
            pbUserData.getFightBuilder().setStage(isFull ? userStage.takeInitBuilder() : userStage.takeBuilder());
        }
        else if (object instanceof UserMonsterTideInfo userMonsterTideInfo) {
            pbUserData.getFightBuilder().setMonsterTideInfo(isFull ? userMonsterTideInfo.takeInitBuilder() : userMonsterTideInfo.takeBuilder());
        }
        else if (object instanceof UserMail usermail) {
            pbUserData.getMailBuilder().putMailList(usermail.getId(),isFull ? usermail.takeInitBuilder().build() : usermail.takeBuilder().build());
        }
        else if (object instanceof UserFeastInfo userFeastInfo) {
            pbUserData.getFeastBuilder().setUserFeastInfo(isFull ? userFeastInfo.takeInitBuilder() : userFeastInfo.takeBuilder());
        }
        else if (object instanceof UserFeastRecord userFeastRecord) {
            pbUserData.getFeastBuilder().putCreateList(userFeastRecord.getId(),isFull ? userFeastRecord.takeInitBuilder().build() : userFeastRecord.takeBuilder().build());
        }
        else if (object instanceof UserFeastPopup userFeastPopup) {
            pbUserData.getFeastBuilder().putPopupList(userFeastPopup.getId(),isFull ? userFeastPopup.takeInitBuilder().build() : userFeastPopup.takeBuilder().build());
        }

        else if (object instanceof UserSecretaryFragment userSecretaryFragment) {
            pbUserData.getSecretaryBuilder().putFragmentList(userSecretaryFragment.getSecretaryId(),isFull ? userSecretaryFragment.takeInitBuilder().build() : userSecretaryFragment.takeBuilder().build());
        }
        else if (object instanceof UserChildInfo userChildInfo){
            pbUserData.getChildBuilder().setChildInfo(isFull ? userChildInfo.takeInitBuilder() : userChildInfo.takeBuilder());
        }
        else if (object instanceof UserChildCls userChildCls){
            pbUserData.getChildBuilder().putClsChildList(userChildCls.getClsId(),isFull ? userChildCls.takeInitBuilder().build() : userChildCls.takeBuilder().build());
        }
        else if (object instanceof UserChildUnmarried userChildUnmarried){
            pbUserData.getChildBuilder().putUnmarriedChildList(userChildUnmarried.getId(),isFull ? userChildUnmarried.takeInitBuilder().build() : userChildUnmarried.takeBuilder().build());
        }
        else if (object instanceof UserChildAlone userChildAlone){
            pbUserData.getChildBuilder().putAloneChildList(userChildAlone.getId(),isFull ? userChildAlone.takeInitBuilder().build() : userChildAlone.takeBuilder().build());
        }
        else if (object instanceof UserChildMarry userChildMarry){
            pbUserData.getChildBuilder().putMarryChildList(userChildMarry.getId(),isFull ? userChildMarry.takeInitBuilder().build() : userChildMarry.takeBuilder().build());
        }
        else if (object instanceof UserShopLimit userShopLimit) {
            pbUserData.getShopBuilder().putBuyList(userShopLimit.getShopType(),isFull ? userShopLimit.takeInitBuilder().build() : userShopLimit.takeBuilder().build());
        }
        else if (object instanceof UserTigerDraw userTigerDraw) {
            pbUserData.getDrawBuilder().setTigerDraw(isFull ? userTigerDraw.takeInitBuilder().build() : userTigerDraw.takeBuilder().build());
        }
        else if (object instanceof UserPatrol userPatrol) {
            pbUserData.getPatrolBuilder().setPatrol(isFull ? userPatrol.takeInitBuilder().build() : userPatrol.takeBuilder().build());
        }
        else if (object instanceof UserSnatchScore userSnatchScore) {
            pbUserData.getFightBuilder().setSnatchScore(isFull ? userSnatchScore.takeInitBuilder().build() : userSnatchScore.takeBuilder().build());
        }
        else if (object instanceof UserSnatchInfo userSnatchInfo) {
            pbUserData.getFightBuilder().setSnatchInfo(isFull ? userSnatchInfo.takeInitBuilder().build() : userSnatchInfo.takeBuilder().build());
        }
        else if (object instanceof UserSnatchPartner userSnatchPartner) {
            pbUserData.getFightBuilder().putSnatchPartner(userSnatchPartner.getPartnerId(), isFull ? userSnatchPartner.takeInitBuilder().build() : userSnatchPartner.takeBuilder().build());
        }
        else if (object instanceof UserSnatchRecord userSnatchRecord) {
            pbUserData.getFightBuilder().putSnatchRecord(userSnatchRecord.getId(), isFull ? userSnatchRecord.takeInitBuilder().build() : userSnatchRecord.takeBuilder().build());
        }
        else if (object instanceof UserSnatchEnemy userSnatchEnemy) {
            pbUserData.getFightBuilder().putEnemyList(userSnatchEnemy.getId(), isFull ? userSnatchEnemy.takeInitBuilder().build() : userSnatchEnemy.takeBuilder().build());
        }
        else if (object instanceof UserSnatchTeam userSnatchTeam) {
            pbUserData.getFightBuilder().putTeamList(userSnatchTeam.getTeamId(), isFull ? userSnatchTeam.takeInitBuilder().build() : userSnatchTeam.takeBuilder().build());
        }
        else if (object instanceof UserFlorist userFlorist) {
            pbUserData.getFloristBuilder().setFlorist(isFull ? userFlorist.takeInitBuilder().build() : userFlorist.takeBuilder().build());
        } else if (object instanceof UserFloristTask userFloristTask) {
            pbUserData.getFloristBuilder().putTask(userFloristTask.getTaskId(), isFull ? userFloristTask.takeInitBuilder().build() : userFloristTask.takeBuilder().build());
        } else if (object instanceof UserAct userActDays){
            pbUserData.getActDaysBuilder().putAct(userActDays.getId(), isFull ? userActDays.takeInitBuilder().build() : userActDays.takeBuilder().build());
        } else if (object instanceof UserActDayTask userActDayTask) {
            pbUserData.getActDaysBuilder().putTask(userActDayTask.getTaskType(), isFull ? userActDayTask.takeInitBuilder().build() : userActDayTask.takeBuilder().build());
        }
        else if (object instanceof UserActTaskReward userActTaskReward){
            pbUserData.getOnceActBuilder().getCityLevelRewardBuilder().setCityReward(isFull ? userActTaskReward.takeInitBuilder().build() : userActTaskReward.takeBuilder().build());
        }
        else if (object instanceof UserDecorate userDecorate) {
            pbUserData.getSystemBuilder().putDecotateList(userDecorate.getDecorateId(), userDecorate.takeInitBuilder().build());
        }
        else if (object instanceof UserTitle userTitle) {
            pbUserData.getSystemBuilder().putTitleList(userTitle.getDecorateId(), isFull ? userTitle.takeInitBuilder().build() : userTitle.takeBuilder().build());
        }
        else if (object instanceof UserTaskValue userTaskValue) {
            pbUserData.getTaskBuilder().putTaskValue(userTaskValue.getTaskId(), isFull ? userTaskValue.takeInitBuilder().build() : userTaskValue.takeBuilder().build());
        }
        else if (object instanceof UserCityTaskReward userCityTaskReward) {
            pbUserData.getTaskBuilder().putCityTaskReward(userCityTaskReward.getTaskId(), isFull ? userCityTaskReward.takeInitBuilder().build() : userCityTaskReward.takeBuilder().build());
        }
        else if (object instanceof UserMainTask userMainTask) {
            pbUserData.getTaskBuilder().putMainTask(userMainTask.getTaskId(), isFull ? userMainTask.takeInitBuilder().build() : userMainTask.takeBuilder().build());
        }
        else if (object instanceof UserAchieve userAchieve) {
            pbUserData.getTaskBuilder().putAchieve(userAchieve.getTaskId(), isFull ? userAchieve.takeInitBuilder().build() : userAchieve.takeBuilder().build());
        }
        else if (object instanceof UserDayTask userDayTask) {
            pbUserData.getTaskBuilder().putDayTask(userDayTask.getTaskId(), isFull ? userDayTask.takeInitBuilder().build() : userDayTask.takeBuilder().build());
        }
        else if (object instanceof UserHonor userHonor) {
            pbUserData.getTaskBuilder().putHonor(userHonor.getHonorType(), isFull ? userHonor.takeInitBuilder().build() : userHonor.takeBuilder().build());
        }
        else if (object instanceof UserIapGiftPush userIapGiftPush) {
            pbUserData.getIapBuilder().putPushGift(userIapGiftPush.getIapGiftId(), isFull ? userIapGiftPush.takeInitBuilder().build() : userIapGiftPush.takeBuilder().build());
        }else if (object instanceof UserIapGift userIapGift) {
                pbUserData.getIapBuilder().putBuyList(userIapGift.getIapGiftId(), isFull ? userIapGift.takeInitBuilder().build() : userIapGift.takeBuilder().build());
        } else if (object instanceof UserGrowthFund userGrowthFund) {
            pbUserData.getIapBuilder().putGrowthFundList(userGrowthFund.getType(),isFull ? userGrowthFund.takeInitBuilder().build() : userGrowthFund.takeBuilder().build());
        } else if (object instanceof UserPrivilegeCard userPrivilegeCard) {
            pbUserData.getIapBuilder().putPrivilegeCardList(userPrivilegeCard.getType(),isFull ? userPrivilegeCard.takeInitBuilder().build() : userPrivilegeCard.takeBuilder().build());
        } else if (object instanceof UserSign userSign) {
            pbUserData.getOnceActBuilder().setUserSign(isFull ? userSign.takeInitBuilder().build() : userSign.takeBuilder().build());
        } else if (object instanceof UserOnlineEvent userOnlineEvent) {
            pbUserData.getEventBuilder().putOnlineList(userOnlineEvent.getId(), isFull ? userOnlineEvent.takeInitBuilder().build() : userOnlineEvent.takeBuilder().build());
        } else if (object instanceof UserEvent userEvent) {
            pbUserData.getEventBuilder().putNormalList(userEvent.getId(), isFull ? userEvent.takeInitBuilder().build() : userEvent.takeBuilder().build());
        } else if (object instanceof UserOnlineEventInfo userOnlineEventInfo) {
            pbUserData.getEventBuilder().setUserOnlineEventInfo(isFull ? userOnlineEventInfo.takeInitBuilder().build() : userOnlineEventInfo.takeBuilder().build());
        }
        else if (object instanceof UserCaveInfo userCaveInfo) {
            pbUserData.getCaveBuilder().setCaveInfo(isFull ? userCaveInfo.takeInitBuilder() : userCaveInfo.takeBuilder());
        }
        else if (object instanceof UserCaveLocation userCaveLocation) {
            pbUserData.getCaveBuilder().setCaveLocation(isFull ? userCaveLocation.takeInitBuilder() : userCaveLocation.takeBuilder());
        }
        else if (object instanceof UserCaveRecord userCaveRecord) {
            pbUserData.getCaveBuilder().putCaveRecord(userCaveRecord.getId(), isFull ? userCaveRecord.takeInitBuilder().build() : userCaveRecord.takeBuilder().build());
        }
        else if (object instanceof UserRestaurantInfo userRestaurantInfo) {
            pbUserData.getRestaurantBuilder().setRestaurantInfo(isFull ? userRestaurantInfo.takeInitBuilder() : userRestaurantInfo.takeBuilder());
        }
        else if (object instanceof UserRestaurantFood userRestaurantFood) {
            pbUserData.getRestaurantBuilder().putFood(userRestaurantFood.getFoodId(), isFull ? userRestaurantFood.takeInitBuilder().build() : userRestaurantFood.takeBuilder().build());
        }
        else if (object instanceof UserRestaurantRoom userRestaurantRoom) {
            pbUserData.getRestaurantBuilder().putRoom(userRestaurantRoom.getRestaurantId(), isFull ? userRestaurantRoom.takeInitBuilder().build() : userRestaurantRoom.takeBuilder().build());
        }
        else if (object instanceof UserRankAct userActTopRank) {
            pbUserData.getRankActBuilder().putActInfo(userActTopRank.getActId(), isFull ? userActTopRank.takeInitBuilder().build() : userActTopRank.takeBuilder().build());
        } else if (object instanceof UserCrossRankAct userActTopCrossRank) {
            pbUserData.getRankActBuilder().putCrossActInfo(userActTopCrossRank.getActId(), isFull ? userActTopCrossRank.takeInitBuilder().build() : userActTopCrossRank.takeBuilder().build());
        } else if (object instanceof UserRankActTask userRankActTask) {
            pbUserData.getRankActBuilder().putTaskInfo(userRankActTask.getTaskType(), isFull ? userRankActTask.takeInitBuilder().build() : userRankActTask.takeBuilder().build());
        } else if (object instanceof UserCrossRankActTask userCrossRankActTask) {
            pbUserData.getRankActBuilder().putCrossTaskInfo(userCrossRankActTask.getTaskType(), isFull ? userCrossRankActTask.takeInitBuilder().build() : userCrossRankActTask.takeBuilder().build());
        } else if (object instanceof UserRechargeActTask rechargeActTask) {
            pbUserData.getRankActBuilder().putRechargeTaskInfo(rechargeActTask.getTaskType(), isFull ? rechargeActTask.takeInitBuilder().build() : rechargeActTask.takeBuilder().build());
        } else if (object instanceof UserCrossRechargeActTask crossRechargeActTask) {
            pbUserData.getRankActBuilder().putCrossRechargeTaskInfo(crossRechargeActTask.getTaskType(), isFull ? crossRechargeActTask.takeInitBuilder().build() : crossRechargeActTask.takeBuilder().build());
        } else if (object instanceof UserUnion userUnion) {
            pbUserData.getUnionBuilder().setUserUnion(isFull ? userUnion.takeInitBuilder().build() : userUnion.takeBuilder().build());
        } else if (object instanceof UnionInfo unionInfo) {
            pbUserData.getUnionBuilder().setUnionInfo( isFull ? unionInfo.takeInitBuilder().build() : unionInfo.takeBuilder().build());
        } else if (object instanceof UserBuddy userBuddy) {
            pbUserData.getBuddyBuilder().putBuddy(userBuddy.getBuddyId(), isFull ? userBuddy.takeInitBuilder().build() : userBuddy.takeBuilder().build());
        } else if (object instanceof UserBuddyBlack userBuddyBlack) {
            pbUserData.getBuddyBuilder().putBuddyBlcak(userBuddyBlack.getBlackId(), isFull ? userBuddyBlack.takeInitBuilder().build() : userBuddyBlack.takeBuilder().build());
        } else if (object instanceof UserDailySign userDailySign) {
            pbUserData.getOnceActBuilder().setDailySign(isFull ? userDailySign.takeInitBuilder().build() : userDailySign.takeBuilder().build());
        } else if (object instanceof UserActDiscountGift userActDiscountGift) {
            pbUserData.getOnceActBuilder().setDiscountGiftInfo(isFull ? userActDiscountGift.takeInitBuilder().build() : userActDiscountGift.takeBuilder().build());
        } else if (object instanceof UserBuddyApplyInfo userBuddyApplyInfo) {
            pbUserData.getBuddyBuilder().setUserApplyInfo( isFull ? userBuddyApplyInfo.takeInitBuilder().build() : userBuddyApplyInfo.takeBuilder().build());
        } else if (object instanceof UnionBuild unionBuild) {
            pbUserData.getUnionBuilder().putUnionBuildList(unionBuild.getBuildId() ,isFull ? unionBuild.takeInitBuilder().build() : unionBuild.takeBuilder().build());
        } else if (object instanceof UnionDonateInfo unionDonateInfo) {
            pbUserData.getUnionBuilder().setUnionDonateInfo(isFull ? unionDonateInfo.takeInitBuilder().build() : unionDonateInfo.takeBuilder().build());
        } else if (object instanceof UnionActChargeInfo unionActChargeInfo) {
            pbUserData.getUnionBuilder().setUnionActChargeInfo(isFull ? unionActChargeInfo.takeInitBuilder().build() : unionActChargeInfo.takeBuilder().build());
        } else if (object instanceof UnionBusinessTaskInfo unionBusinessTaskInfo) {
            pbUserData.getUnionBuilder().setUnionBusinessTaskInfo(isFull ? unionBusinessTaskInfo.takeInitBuilder().build() : unionBusinessTaskInfo.takeBuilder().build());
        } else if (object instanceof UnionBossInfo unionBossInfo) {
            pbUserData.getUnionBuilder().setUnionBossInfo(isFull ? unionBossInfo.takeInitBuilder().build() : unionBossInfo.takeBuilder().build());
        } else if (object instanceof PBUserUnionMember.Builder pbUserUnionMember) {
            pbUserData.getUnionBuilder().putUserUnionMemberList(pbUserUnionMember.getUserId() , pbUserUnionMember.build());
        } else if (object instanceof UserActDailyScreen userActDailyScreen) {
            pbUserData.getOnceActBuilder().setUserDailyScreen(isFull ? userActDailyScreen.takeInitBuilder().build() : userActDailyScreen.takeBuilder().build());
        } else if (object instanceof UserActDailySupply userActDailySupply) {
            pbUserData.getOnceActBuilder().setDailySupply(isFull ? userActDailySupply.takeInitBuilder().build() : userActDailySupply.takeBuilder().build());
        } else if (object instanceof UserDailyPass userDailyPass) {
            pbUserData.getOnceActBuilder().setUserDailyPass(isFull ? userDailyPass.takeInitBuilder().build() : userDailyPass.takeBuilder().build());
        } else if (object instanceof UserUnionScuffleInfoWeek userUnionScuffleInfo) {
            pbUserData.getUnionBuilder().setScuffleInfo(isFull ? userUnionScuffleInfo.takeInitBuilder().build() : userUnionScuffleInfo.takeBuilder().build());
        } else if (object instanceof UserUnionScuffleWeek userUnionScuffle) {
            pbUserData.getUnionBuilder().setScuffle(isFull ? userUnionScuffle.takeInitBuilder().build() : userUnionScuffle.takeBuilder().build());
        } else if (object instanceof UserUnionScuffleMemberWeek userUnionScuffleMember) {
            pbUserData.getUnionBuilder().addEnemyMemberList(isFull ? userUnionScuffleMember.takeInitBuilder().build() : userUnionScuffleMember.takeBuilder().build());
        } else if (object instanceof UserDailyRaffleDraw userDailyRaffleDraw) {
            pbUserData.getOnceActBuilder().setDailyRaffleDraw(isFull ? userDailyRaffleDraw.takeInitBuilder().build() : userDailyRaffleDraw.takeBuilder().build());
        }else if (object instanceof UserChip userChip) {// 全部更新就行
            pbUserData.getBagBuilder().putChipList(userChip.getChipId(), userChip.takeInitBuilder().build());
        } else if (object instanceof UnionScuffleReportWeek unionScuffleReport) {
            pbUserData.getUnionBuilder().addScuffleReportList(unionScuffleReport.takeInitBuilder());
        } else if (object instanceof UnionHonor unionHonor) {
            pbUserData.getTaskBuilder().putUnionHonor(unionHonor.getHonorType(), isFull ? unionHonor.takeInitBuilder().build() : unionHonor.takeBuilder().build());
        } else if (object instanceof UnionDiscountShopInfo unionDiscountShopInfo) {
            pbUserData.getUnionBuilder().setDiscountShopInfo( isFull ? unionDiscountShopInfo.takeInitBuilder().build() : unionDiscountShopInfo.takeBuilder().build());
        }
        else if (object instanceof UserWorldInfo userWorldInfo) {
            pbUserData.getWorldBuilder().setUserWorldInfo(isFull ? userWorldInfo.takeInitBuilder().build() : userWorldInfo.takeBuilder().build());
        }
        else if (object instanceof UserWorldBossInfo userWorldBossInfo) {
            pbUserData.getWorldBuilder().setWorldBoss(isFull ? userWorldBossInfo.takeInitBuilder().build() : userWorldBossInfo.takeBuilder().build());
        }
        else if (object instanceof UserWorldEventLocation userWorldEventLocation) {
            pbUserData.getWorldBuilder().putEventLocation(userWorldEventLocation.getLocationId(), isFull ? userWorldEventLocation.takeInitBuilder().build() : userWorldEventLocation.takeBuilder().build());
        }
        else if (object instanceof UserWorldPartner userWorldPartner) {
            pbUserData.getWorldBuilder().putPartner(userWorldPartner.getPartnerId(), isFull ? userWorldPartner.takeInitBuilder().build() : userWorldPartner.takeBuilder().build());
        }
        else if (object instanceof UserWorldRecord userWorldRecord) {
            pbUserData.getWorldBuilder().putRecord(userWorldRecord.getId(), isFull ? userWorldRecord.takeInitBuilder().build() : userWorldRecord.takeBuilder().build());
        }
        else if (object instanceof UserWorldTeam userWorldTeam) {
            pbUserData.getWorldBuilder().putTeam(userWorldTeam.getTeamId(), isFull ? userWorldTeam.takeInitBuilder().build() : userWorldTeam.takeBuilder().build());
        }
        else if (object instanceof UserWorldEventLocationTeam userWorldEventLocationTeam) {
            pbUserData.getWorldBuilder().putLocationTeam(userWorldEventLocationTeam.getId(), isFull ? userWorldEventLocationTeam.takeInitBuilder().build() : userWorldEventLocationTeam.takeBuilder().build());
        }
        else if (object instanceof UserActConventionTask  userActConventionTask) {
            pbUserData.getActBuilder().putActConventionTaskList(userActConventionTask.getTaskType(), isFull? userActConventionTask.takeInitBuilder().build() : userActConventionTask.takeBuilder().build());
        }
        else if (object instanceof UnionBoxInfo unionBoxInfo) {
            pbUserData.getUnionBuilder().getUnionBoxMainInfoBuilder().setUnionBoxInfo(isFull ? unionBoxInfo.takeInitBuilder().build() : unionBoxInfo.takeBuilder().build());
        } else if (object instanceof UserUnionBox userUnionBox) {
            pbUserData.getUnionBuilder().getUnionBoxMainInfoBuilder().setUserUnionBox(isFull ? userUnionBox.takeInitBuilder().build() : userUnionBox.takeBuilder().build());
        } else if (object instanceof UserUnionScuffleGiftWeek userUnionScuffleGift) {
            pbUserData.getUnionBuilder().putUnionScuffleGiftList(userUnionScuffleGift.getGiftId(), isFull ? userUnionScuffleGift.takeInitBuilder().build() : userUnionScuffleGift.takeBuilder().build());
        }  else if (object instanceof UserUnionReciprocity userUnionReciprocity) {
            pbUserData.getUnionBuilder().getUnionReciprocityInfoBuilder().setUnionCoin(userUnionReciprocity.getDayGetUnionCoin());
        } else if (object instanceof UnionReciprocityList unionReciprocityList) {
            pbUserData.getUnionBuilder().getUnionReciprocityInfoBuilder().putReciprocityList(unionReciprocityList.getId(), isFull? unionReciprocityList.takeInitBuilder().build() : unionReciprocityList.takeBuilder().build());
        } else if (object instanceof UserUnionScuffleShopWeek unionScuffleShop) {
            pbUserData.getUnionBuilder().putUnionScuffleShopList(unionScuffleShop.getShopId(), isFull ? unionScuffleShop.takeInitBuilder().build() : unionScuffleShop.takeBuilder().build());
        } else if (object instanceof UserSkillEffect userSkillEffect) {
            pbUserData.getSkillBuilder().putEffects(userSkillEffect.getEffectType(), isFull ? userSkillEffect.takeInitBuilder().build() : userSkillEffect.takeBuilder().build());
        } else if (object instanceof UserRankActShop userRankActShop) {
            pbUserData.getRankActBuilder().putShopInfo(userRankActShop.getShopId(), isFull ? userRankActShop.takeInitBuilder().build() : userRankActShop.takeBuilder().build());
        } else if (object instanceof UserCrossRankActShop userCrossRankActShop) {
            pbUserData.getRankActBuilder().putCrossShopInfo(userCrossRankActShop.getShopId(), isFull ? userCrossRankActShop.takeInitBuilder().build() : userCrossRankActShop.takeBuilder().build());
        } else if (object instanceof UserMobileInfo userMobileInfo) {
            pbUserData.getUnionBuilder().getUnionMobileInfoBuilder().setUserMobileInfo( isFull ? userMobileInfo.takeInitBuilder().build() : userMobileInfo.takeBuilder().build());
        } else if (object instanceof UserMobileTaskInfo userMobileTaskInfo) {
            pbUserData.getUnionBuilder().getUnionMobileInfoBuilder().putTaskInfo(userMobileTaskInfo.getTaskId(), isFull ? userMobileTaskInfo.takeInitBuilder().build() : userMobileTaskInfo.takeBuilder().build());
        } else if (object instanceof UnionMobileTaskInfo unionMobileTaskInfo) {
            pbUserData.getUnionBuilder().getUnionMobileInfoBuilder().putUnionTaskInfo(unionMobileTaskInfo.getTaskId(), isFull ? unionMobileTaskInfo.takeInitBuilder().build() : unionMobileTaskInfo.takeBuilder().build());
        } else if (object instanceof UnionMobileInfo unionMobileInfo) {
            pbUserData.getUnionBuilder().getUnionMobileInfoBuilder().setUnionMobileInfo( isFull ? unionMobileInfo.takeInitBuilder().build() : unionMobileInfo.takeBuilder().build());
        }


    }

    // 删除pbuserdata里的数据,相应位置下发 getDefaultInstance
    public static void deletePBUserData(PBUserData.Builder pbUserData, Object object) {
        if (pbUserData == null || object == null) {
            return;
        }
        if (object instanceof UserWeapon userWeapon) {
            pbUserData.getPartnerBuilder().putWeaponList(userWeapon.getId(), PBUserWeapon.getDefaultInstance());
        }
        if (object instanceof UserItem userItem) {
            pbUserData.getBagBuilder().putItemList(userItem.getItemId(), PBUserItem.getDefaultInstance());
        }
        else if (object instanceof UserCityCoord userCityCoord) {
            pbUserData.getBuildBuilder().putCoordList(userCityCoord.getCrood(), PBUserCityCoord.getDefaultInstance());
        }
        else if (object instanceof UserMail usermail) {
            pbUserData.getMailBuilder().putMailList(usermail.getId(), PBUserMail.getDefaultInstance());
        }
        else if (object instanceof UserWorldRecord userWorldRecord) {
            pbUserData.getWorldBuilder().putRecord(userWorldRecord.getId(), PBUserWorldRecord.getDefaultInstance());
        }
        else if (object instanceof UserChildUnmarried userChildUnmarried){
            pbUserData.getChildBuilder().putUnmarriedChildList(userChildUnmarried.getId(), PBUserChildUnmarried.getDefaultInstance());
        }
        else if (object instanceof UserFloristTask userFloristTask) {
            pbUserData.getFloristBuilder().putTask(userFloristTask.getTaskId(), PBUserFloristTask.getDefaultInstance());
        }
        else if (object instanceof UserIapGiftPush userIapGiftPush) {
            pbUserData.getIapBuilder().putPushGift(userIapGiftPush.getIapGiftId(), PBUserIapGiftPush.getDefaultInstance());
        } else if (object instanceof UserOnlineEvent userOnlineEvent) {
            pbUserData.getEventBuilder().putOnlineList(userOnlineEvent.getId(), PBUserOnlineEvent.getDefaultInstance());
        } else if (object instanceof UserEvent userEvent) {
            pbUserData.getEventBuilder().putNormalList(userEvent.getId(), PBUserOnlineEvent.getDefaultInstance());
        } else if (object instanceof UserUnion userUnion) {
            pbUserData.getUnionBuilder().putUserUnionMemberList(userUnion.getId(), PBUserUnionMember.getDefaultInstance());
        } else if (object instanceof UserBuddy userBuddy) {
            pbUserData.getBuddyBuilder().putBuddy(userBuddy.getBuddyId(), PBUserBuddy.getDefaultInstance());
        } else if (object instanceof UserBuddyBlack userBuddyBlack) {
            pbUserData.getBuddyBuilder().putBuddyBlcak(userBuddyBlack.getBlackId(), PBUserBuddy.getDefaultInstance());
        } else if (object instanceof UnionInfo unionInfo) {
            pbUserData.getUnionBuilder().setUnionInfo(PBUnionInfo.getDefaultInstance());
        } else if (object instanceof UserChip  userChip ) {
            pbUserData.getBagBuilder().putChipList(userChip.getChipId(), PBUserChip.getDefaultInstance());
        } else if (object instanceof UnionGiftBoxList unionGiftBoxList) {
            pbUserData.getUnionBuilder().getUnionBoxMainInfoBuilder().putUnionGiftBoxList(unionGiftBoxList.getId(), PBUnionGiftBoxList.getDefaultInstance());
        } else if (object instanceof UnionReciprocityList unionReciprocityList) {
            pbUserData.getUnionBuilder().getUnionReciprocityInfoBuilder().putReciprocityList(unionReciprocityList.getId(), PBUnionReciprocityList.getDefaultInstance());
        }
        else if (object instanceof UserWorldEventLocationTeam userWorldEventLocationTeam) {
            pbUserData.getWorldBuilder().putLocationTeam(userWorldEventLocationTeam.getId(), PBUserWorldEventLocationTeam.getDefaultInstance());
        }
    }
}
